//
//  MoneyChoses.m
//  Ten
//
//  Created by anfuer on 2018/11/27.
//  Copyright © 2018年 xg韦. All rights reserved.
//

#import "MoneyChoses.h"
#import "SFDualWaySlider.h"
@implementation MoneyChoses

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (IBAction)removeBtna:(UIButton *)sender {
//    [self removeFromSuperview];
    self.hidden=YES;
}

- (IBAction)btna:(UIButton *)sender {
    self.completion(_moneyLb.text);
     self.hidden=YES;
}

+(MoneyChoses *)instanceCenterViewWithType;
{
    NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"MoneyChoses" owner:nil options:nil];
    MoneyChoses *tmpCustomView = [nib objectAtIndex:0];
    
    return tmpCustomView;
}
-(instancetype)initWithFrame:(CGRect)frame{
    self =[super initWithFrame:frame];
    if (self) {
        
    }
    return  self;
}

-(void)initMoney
{
    SFDualWaySlider *slider = [[SFDualWaySlider alloc] initWithFrame:CGRectMake(0, 50,DEVW, 70) minValue:0 maxValue:30 blockSpaceValue:0];
    slider.progressRadius = 5;
    [slider.minIndicateView setTitle:@"不限"];
    [slider.maxIndicateView setTitle:@"不限"];
    slider.lightColor = WXG_Color(68, 199, 255);
    slider.minIndicateView.backIndicateColor = WXG_Color(68, 199, 255);
    slider.maxIndicateView.backIndicateColor = WXG_Color(68, 199, 255);
    slider.sliderValueChanged = ^(CGFloat minValue, CGFloat maxValue) {
        _moneyLb.text=[NSString stringWithFormat:@"%.0f000-%.0f000",minValue,maxValue];
        
    };
    
    //设置标题，如果需要设置默认值 最好先写这个，否则设置默认值后不会第一时间触发
    slider.getMinTitle = ^NSString *(CGFloat minValue) {
        if (floor(minValue) == 0.f) {
            return @"不限";
        }else{
            return [NSString stringWithFormat:@"%.fK",floor(minValue)];
        }
        
    };
    
    slider.getMaxTitle = ^NSString *(CGFloat maxValue) {
        if (floor(maxValue) == 80.f) {
            return @"不限";
        }else{
            return [NSString stringWithFormat:@"%.fK",floor(maxValue)];
        }
    };
    
    slider.currentMinValue = 0;
    slider.currentMaxValue = 30;
    //分段 表示前部分占比80%  所在值范围为[0,30]  即剩下的 20%滑动距离 值范围为[30，80]
    slider.frontScale = 0.8;
    slider.frontValue = 30;
    
    slider.indicateViewOffset = 10;
    slider.indicateViewWidth = 40;
    
    [_backview addSubview:slider];
}

@end
